package com.vanke.devops.domain.manager.aliyun.config;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import com.vanke.devops.domain.properties.AliyunProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 陈景阳
 * @since 2018/3/14
 */
@Configuration
@EnableConfigurationProperties(AliyunProperties.class)
public class AliyunMonitorConfig {

    @Autowired
    private AliyunProperties aliyunProperties;

    @Bean
    public IAcsClient getIAcsClient(){
        IClientProfile profile = DefaultProfile.getProfile(aliyunProperties.getRegion(),
                aliyunProperties.getId(), aliyunProperties.getSecret());
        return new DefaultAcsClient(profile);
    }
}
